package com.lottery.im.module.result.adapter;

import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lottery.im.R;
import com.lottery.im.api.result.entity.LongDragonInfo;
import java.util.List;

public class LongDragonAdapter extends BaseQuickAdapter<LongDragonInfo, BaseViewHolder> {

  private OnItemCheckClickListener mOnItemCheckClickListener;

  public LongDragonAdapter(@Nullable List<LongDragonInfo> data) {
    super(R.layout.item_long_dragon_list, data);
  }

  @Override protected void convert(final BaseViewHolder helper, LongDragonInfo item) {
    helper.setText(R.id.tv_game_name, item.getGameName());
    helper.setText(R.id.tv_game_type, item.getPlayName() + ":" + item.getPlayType());
    helper.setText(R.id.tv_game_num, item.getGameNum() + "期");
    TextView mBtnCheck = helper.getView(R.id.tv_check);
    mBtnCheck.setOnClickListener(v -> {
      if (null != mOnItemCheckClickListener) {
        int position = helper.getAdapterPosition();
        if (position > 0) {
          mOnItemCheckClickListener.OnItemCheckClick(helper.getAdapterPosition() - 1);
        }
      }
    });
  }

  public void setOnItemCheckClickListener(OnItemCheckClickListener onItemCheckClickListener) {
    mOnItemCheckClickListener = onItemCheckClickListener;
  }

  public interface OnItemCheckClickListener {
    void OnItemCheckClick(int position);
  }
}
